#include<stdio.h>
//void set_arr(int arr[10], int sz)
//{
//	for (int i = 0;i < sz;i++)
//		arr[i] = -1;
//}
//void print_arr(int arr1[], int as)
//{
//	for (int i = 0;i < as;i++)
//		printf("%d ", arr1[i]);
//}
//int main()
//{
//	int arr[10] = { 0 };
//	int sz = (sizeof(arr) / sizeof(arr[0]));
//	set_arr(arr, sz);
//	print_arr(arr, sz);
//	return 0;
//}
_Bool get_year(int year)
{
	if ((year % 4 == 0) && (year % 100 != 0)||(year%400==0))
		return 1;
	else
		return 0;
}
int get_days_of_month(int y, int month)
{
	int day1 = 0;
	switch (month)
	{
	case 1:
		day1 = 31;
		break;
	case 2:
		if (get_year(y))
			day1 = 29;
		else
			day1 = 28;
		break;
	case 3:
		day1 = 31;
		break;
	case 4:
		day1 = 30;
		break;
	case 5:
		day1 = 31;
		break;
	case 6:
		day1 = 30;
		break;
	case 7:
		day1 = 31;
		break;
	case 8:
		day1 = 31;
		break;
	case 9:
		day1 = 30;
		break;
	case 10:
		day1 = 31;
		break;
	case 11:
		day1 = 30;
		break;
	case 12:
		day1 = 31;
		break;
	}
	return day1;
}
int main()
{
	int year = 0;
	int month = 0;
	scanf_s("%d%d", &year, &month);
	int day = get_days_of_month(year, month);
	printf("%d\n", day);
	return 0;
}